﻿using EasyXaf.EntityDesigner.BusinessObjects;
using EasyXaf.EntityDesigner.BusinessObjects.Entities.EntityProperties;

namespace EasyXaf.EntityDesigner.Commands.PropertyTypeBuilders;

public class DateTimeTypeBuilder : IPropertyTypeBuilder
{
    public string[] TypeAliasNames => ["DateTime", "DateTime?", "DateTime!", "datetime", "datetime?", "datetime!"];

    public void Build(EntityProperty property, string typeName, string[] typeParams)
    {
        property.PropertyType = PropertyType.DateTime;

        if (typeName.EndsWith('?'))
        {
            property.IsNullable = DefaultBoolean.True;
        }
    }
}
